import 'package:seedfour/generated/json/base/json_convert_content.dart';
import 'package:seedfour/app/models/income_order_list_entity.dart';

IncomeOrderListEntity $IncomeOrderListEntityFromJson(
    Map<String, dynamic> json) {
  final IncomeOrderListEntity incomeOrderListEntity = IncomeOrderListEntity();
  final int? total = jsonConvert.convert<int>(json['total']);
  if (total != null) {
    incomeOrderListEntity.total = total;
  }
  final String? sumAmount = jsonConvert.convert<String>(json['sumAmount']);
  if (sumAmount != null) {
    incomeOrderListEntity.sumAmount = sumAmount;
  }
  final String? plusAmount = jsonConvert.convert<String>(json['plusAmount']);
  if (plusAmount != null) {
    incomeOrderListEntity.plusAmount = plusAmount;
  }
  final String? minusAmount = jsonConvert.convert<String>(json['minusAmount']);
  if (minusAmount != null) {
    incomeOrderListEntity.minusAmount = minusAmount;
  }
  final List<IncomeOrderInfo>? data = (json['data'] as List<dynamic>?)
      ?.map(
          (e) => jsonConvert.convert<IncomeOrderInfo>(e) as IncomeOrderInfo)
      .toList();
  if (data != null) {
    incomeOrderListEntity.data = data;
  }
  final bool? hasBoxPermission = jsonConvert.convert<bool>(
      json['hasBoxPermission']);
  if (hasBoxPermission != null) {
    incomeOrderListEntity.hasBoxPermission = hasBoxPermission;
  }
  return incomeOrderListEntity;
}

Map<String, dynamic> $IncomeOrderListEntityToJson(
    IncomeOrderListEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['total'] = entity.total;
  data['sumAmount'] = entity.sumAmount;
  data['plusAmount'] = entity.plusAmount;
  data['minusAmount'] = entity.minusAmount;
  data['data'] = entity.data?.map((v) => v.toJson()).toList();
  data['hasBoxPermission'] = entity.hasBoxPermission;
  return data;
}

extension IncomeOrderListEntityExtension on IncomeOrderListEntity {
  IncomeOrderListEntity copyWith({
    int? total,
    String? sumAmount,
    String? plusAmount,
    String? minusAmount,
    List<IncomeOrderInfo>? data,
    bool? hasBoxPermission,
  }) {
    return IncomeOrderListEntity()
      ..total = total ?? this.total
      ..sumAmount = sumAmount ?? this.sumAmount
      ..plusAmount = plusAmount ?? this.plusAmount
      ..minusAmount = minusAmount ?? this.minusAmount
      ..data = data ?? this.data
      ..hasBoxPermission = hasBoxPermission ?? this.hasBoxPermission;
  }
}

IncomeOrderInfo $IncomeOrderInfoFromJson(Map<String, dynamic> json) {
  final IncomeOrderInfo incomeOrderInfo = IncomeOrderInfo();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    incomeOrderInfo.id = id;
  }
  final String? attach = jsonConvert.convert<String>(json['attach']);
  if (attach != null) {
    incomeOrderInfo.attach = attach;
  }
  final String? creatorName = jsonConvert.convert<String>(json['creatorName']);
  if (creatorName != null) {
    incomeOrderInfo.creatorName = creatorName;
  }
  final int? createdAt = jsonConvert.convert<int>(json['createdAt']);
  if (createdAt != null) {
    incomeOrderInfo.createdAt = createdAt;
  }
  final int? updatedAt = jsonConvert.convert<int>(json['updatedAt']);
  if (updatedAt != null) {
    incomeOrderInfo.updatedAt = updatedAt;
  }
  final String? uid = jsonConvert.convert<String>(json['uid']);
  if (uid != null) {
    incomeOrderInfo.uid = uid;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    incomeOrderInfo.title = title;
  }
  final String? pTitle = jsonConvert.convert<String>(json['pTitle']);
  if (pTitle != null) {
    incomeOrderInfo.pTitle = pTitle;
  }
  final int? orderAmount = jsonConvert.convert<int>(json['orderAmount']);
  if (orderAmount != null) {
    incomeOrderInfo.orderAmount = orderAmount;
  }
  final int? payAmount = jsonConvert.convert<int>(json['payAmount']);
  if (payAmount != null) {
    incomeOrderInfo.payAmount = payAmount;
  }
  final int? invoicedAt = jsonConvert.convert<int>(json['invoicedAt']);
  if (invoicedAt != null) {
    incomeOrderInfo.invoicedAt = invoicedAt;
  }
  final String? mobile = jsonConvert.convert<String>(json['mobile']);
  if (mobile != null) {
    incomeOrderInfo.mobile = mobile;
  }
  final int? collectionDate = jsonConvert.convert<int>(json['collectionDate']);
  if (collectionDate != null) {
    incomeOrderInfo.collectionDate = collectionDate;
  }
  final int? orderType = jsonConvert.convert<int>(json['orderType']);
  if (orderType != null) {
    incomeOrderInfo.orderType = orderType;
  }
  final String? invoice = jsonConvert.convert<String>(json['invoice']);
  if (invoice != null) {
    incomeOrderInfo.invoice = invoice;
  }
  final int? invoiceStatus = jsonConvert.convert<int>(json['invoiceStatus']);
  if (invoiceStatus != null) {
    incomeOrderInfo.invoiceStatus = invoiceStatus;
  }
  final String? allocContent = jsonConvert.convert<String>(
      json['allocContent']);
  if (allocContent != null) {
    incomeOrderInfo.allocContent = allocContent;
  }
  final dynamic failReason = json['failReason'];
  if (failReason != null) {
    incomeOrderInfo.failReason = failReason;
  }
  final String? remark = jsonConvert.convert<String>(json['remark']);
  if (remark != null) {
    incomeOrderInfo.remark = remark;
  }
  final int? flowId = jsonConvert.convert<int>(json['flowId']);
  if (flowId != null) {
    incomeOrderInfo.flowId = flowId;
  }
  final String? operatorUid = jsonConvert.convert<String>(json['operatorUid']);
  if (operatorUid != null) {
    incomeOrderInfo.operatorUid = operatorUid;
  }
  final String? editor = jsonConvert.convert<String>(json['editor']);
  if (editor != null) {
    incomeOrderInfo.editor = editor;
  }
  final String? marginAmount = jsonConvert.convert<String>(
      json['marginAmount']);
  if (marginAmount != null) {
    incomeOrderInfo.marginAmount = marginAmount;
  }
  final String? marginDate = jsonConvert.convert<String>(json['marginDate']);
  if (marginDate != null) {
    incomeOrderInfo.marginDate = marginDate;
  }
  final String? creator = jsonConvert.convert<String>(json['creator']);
  if (creator != null) {
    incomeOrderInfo.creator = creator;
  }
  final int? orderStatus = jsonConvert.convert<int>(json['orderStatus']);
  if (orderStatus != null) {
    incomeOrderInfo.orderStatus = orderStatus;
  }
  final IncomeOrderSettle? settle = jsonConvert.convert<IncomeOrderSettle>(
      json['settle']);
  if (settle != null) {
    incomeOrderInfo.settle = settle;
  }
  final String? orderAmountStr = jsonConvert.convert<String>(
      json['orderAmountStr']);
  if (orderAmountStr != null) {
    incomeOrderInfo.orderAmountStr = orderAmountStr;
  }
  final String? payAmountStr = jsonConvert.convert<String>(
      json['payAmountStr']);
  if (payAmountStr != null) {
    incomeOrderInfo.payAmountStr = payAmountStr;
  }
  return incomeOrderInfo;
}

Map<String, dynamic> $IncomeOrderInfoToJson(IncomeOrderInfo entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['attach'] = entity.attach;
  data['creatorName'] = entity.creatorName;
  data['createdAt'] = entity.createdAt;
  data['updatedAt'] = entity.updatedAt;
  data['uid'] = entity.uid;
  data['title'] = entity.title;
  data['pTitle'] = entity.pTitle;
  data['orderAmount'] = entity.orderAmount;
  data['payAmount'] = entity.payAmount;
  data['invoicedAt'] = entity.invoicedAt;
  data['mobile'] = entity.mobile;
  data['collectionDate'] = entity.collectionDate;
  data['orderType'] = entity.orderType;
  data['invoice'] = entity.invoice;
  data['invoiceStatus'] = entity.invoiceStatus;
  data['allocContent'] = entity.allocContent;
  data['failReason'] = entity.failReason;
  data['remark'] = entity.remark;
  data['flowId'] = entity.flowId;
  data['operatorUid'] = entity.operatorUid;
  data['editor'] = entity.editor;
  data['marginAmount'] = entity.marginAmount;
  data['marginDate'] = entity.marginDate;
  data['creator'] = entity.creator;
  data['orderStatus'] = entity.orderStatus;
  data['settle'] = entity.settle?.toJson();
  data['orderAmountStr'] = entity.orderAmountStr;
  data['payAmountStr'] = entity.payAmountStr;
  return data;
}

extension IncomeOrderInfoExtension on IncomeOrderInfo {
  IncomeOrderInfo copyWith({
    String? id,
    String? attach,
    String? creatorName,
    int? createdAt,
    int? updatedAt,
    String? uid,
    String? title,
    String? pTitle,
    int? orderAmount,
    int? payAmount,
    int? invoicedAt,
    String? mobile,
    int? collectionDate,
    int? orderType,
    String? invoice,
    int? invoiceStatus,
    String? allocContent,
    dynamic failReason,
    String? remark,
    int? flowId,
    String? operatorUid,
    String? editor,
    String? marginAmount,
    String? marginDate,
    String? creator,
    int? orderStatus,
    IncomeOrderSettle? settle,
    String? orderAmountStr,
    String? payAmountStr,
  }) {
    return IncomeOrderInfo()
      ..id = id ?? this.id
      ..attach = attach ?? this.attach
      ..creatorName = creatorName ?? this.creatorName
      ..createdAt = createdAt ?? this.createdAt
      ..updatedAt = updatedAt ?? this.updatedAt
      ..uid = uid ?? this.uid
      ..title = title ?? this.title
      ..pTitle = pTitle ?? this.pTitle
      ..orderAmount = orderAmount ?? this.orderAmount
      ..payAmount = payAmount ?? this.payAmount
      ..invoicedAt = invoicedAt ?? this.invoicedAt
      ..mobile = mobile ?? this.mobile
      ..collectionDate = collectionDate ?? this.collectionDate
      ..orderType = orderType ?? this.orderType
      ..invoice = invoice ?? this.invoice
      ..invoiceStatus = invoiceStatus ?? this.invoiceStatus
      ..allocContent = allocContent ?? this.allocContent
      ..failReason = failReason ?? this.failReason
      ..remark = remark ?? this.remark
      ..flowId = flowId ?? this.flowId
      ..operatorUid = operatorUid ?? this.operatorUid
      ..editor = editor ?? this.editor
      ..marginAmount = marginAmount ?? this.marginAmount
      ..marginDate = marginDate ?? this.marginDate
      ..creator = creator ?? this.creator
      ..orderStatus = orderStatus ?? this.orderStatus
      ..settle = settle ?? this.settle
      ..orderAmountStr = orderAmountStr ?? this.orderAmountStr
      ..payAmountStr = payAmountStr ?? this.payAmountStr;
  }
}

IncomeOrderSettle $IncomeOrderSettleFromJson(Map<String, dynamic> json) {
  final IncomeOrderSettle incomeOrderSettle = IncomeOrderSettle();
  final String? ratio = jsonConvert.convert<String>(json['ratio']);
  if (ratio != null) {
    incomeOrderSettle.ratio = ratio;
  }
  final String? settleAmount = jsonConvert.convert<String>(
      json['settleAmount']);
  if (settleAmount != null) {
    incomeOrderSettle.settleAmount = settleAmount;
  }
  return incomeOrderSettle;
}

Map<String, dynamic> $IncomeOrderSettleToJson(IncomeOrderSettle entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['ratio'] = entity.ratio;
  data['settleAmount'] = entity.settleAmount;
  return data;
}

extension IncomeOrderSettleExtension on IncomeOrderSettle {
  IncomeOrderSettle copyWith({
    String? ratio,
    String? settleAmount,
  }) {
    return IncomeOrderSettle()
      ..ratio = ratio ?? this.ratio
      ..settleAmount = settleAmount ?? this.settleAmount;
  }
}